<%--
 *  File:    VisitPlanTempletSelectList.jsp
 *  @Author: tendyhu
 *  Date:    2009-10-17 ??02:52:12

 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<%
  //init param
  Category cat = Category.getInstance("jsp.VisitPlanTempletSelectList");  
  String strModuleName = "CRM";  
  String privilegeCode = "ALL";
%>

<%
  HashMap userInfo = (HashMap)session.getAttribute("userinfo");  
  Integer nCurOrgId = (Integer)userInfo.get("orgid");
%>

<%@ include file="/inc/PageDefault.inc"%>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="p_selectlisttree" />
<%
  Vector categories = (Vector)pageContext.getAttribute("contacttree");

  if(categories == null)
    categories = new Vector();
  cat.debug("The categories is :" + categories.size() + categories);
  OvalTree initTree = new OvalTree(categories,"areaid","parentareaid","grade");
  initTree.setRecursiveLimit(2000);
  Vector categoryTree = (Vector)initTree.getTreeVector(new Integer(-1000),1);  
  cat.debug("The tree's size is :" + categoryTree.size());
  cat.debug("The tree is :" + categoryTree);
%>
<%
  StringBuffer strParams=new StringBuffer();
  if(request.getParameter("orgid")!=null)
  {
  	strParams.append("&orgid=").append(request.getParameter("orgid"));
  }
  if(request.getParameter("ishistory")!=null)
  {
  	strParams.append("&ishistory=").append(request.getParameter("ishistory"));
  }
  if(request.getParameter("contactid")!=null)
  {
  	strParams.append("&contactid=").append(request.getParameter("contactid"));
  }
  if(request.getParameter("year")!=null)
  {
  	strParams.append("&year=").append(request.getParameter("year"));
  }
  if(request.getParameter("monthofyear")!=null)
  {
  	strParams.append("&monthofyear=").append(request.getParameter("monthofyear"));
  }
  if(request.getParameter("weekofmonth")!=null)
  {
  	strParams.append("&weekofmonth=").append(request.getParameter("weekofmonth"));
  }
  if(request.getParameter("dayofweek")!=null)
  {
  	strParams.append("&dayofweek=").append(request.getParameter("dayofweek"));
  }
  
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css"
	type="text/css">
<SCRIPT language=JavaScript1.2 src="../css/menu.js"></SCRIPT>
<script language="JavaScript"
	src="../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../js/FuncLib.js"></script>
<link rel="stylesheet" href="../css/cn/widget.css" type="text/css">
<script language="JavaScript" src="../js/opal2/mootools.js"></script>
<script language="JavaScript" src="../js/opal2/opal2-mini.js"></script>
<script language="JavaScript">

parent.rightFrame.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
function page_view(id,visitplantempletid,grade,isbottom,cid){
    	  document.contacttreeform.contactid.value = id;
    	  document.contacttreeform.visitplantempletid.value = visitplantempletid;
    	  document.contacttreeform.grade.value = grade; 
    	  document.contacttreeform.isbottom.value = isbottom; 
    	  document.contacttreeform.cid.value = cid;    	 
    	  
    	  if(id == null || id.length == 0 || id == "" || id < 0 || id == -1){
    	  	alert('<%=message.getMessageDesc("PLEASE_SELECT") %>');
    	  	return;
    	  }
    	
    		 var link= "VisitPlanTempletSelectDetail.jsp?visitplantempletid="+visitplantempletid+"<%=strParams.toString()%>&<%=OvalTools.randomURL()%>";  
    	
    	 parent.rightFrame.location.href = link;
}

function page_ajaxgo(){
        $('contacttreeview').selectedNode.clearChildren();
    	}
    	
			window.addEvent('domready', function() {	
				opal.widget.TreeView.image.path = '../images/';	
				var treeView = new opal.widget.TreeView({
					id: 'contacttreeview'
				});
				
				treeView.ajaxHelper.pageName = 'p_selectlisttree';
				treeView.ajaxHelper.actionName = 'gobyajax';	
				treeView.ajaxHelper.staticParams = '';	
				treeView.ajaxHelper.dynamicParams = '';	
				treeView.DataPackName = 'contacttree';								
				treeView.idName = 'contactid';
				treeView.textName = 'templetname';
				treeView.isBottomName = 'isbottom';				
				treeView.onRequestData = function(Node, ajaxHelper){
				  if ($defined(Node.grade)){				  
                   ajaxHelper.dynamicParams = 'contactid=' + Node.id+'&orgid=<%=JspHelper.filterNull( nCurOrgId )%>';					  
				  }else{				 
				    ajaxHelper.dynamicParams = 'grade=1&contactid=<%=request.getParameter("contactid")%>&orgid=<%=JspHelper.filterNull( nCurOrgId )%>';					  
				  }
				};
								
				treeView.onNodeGetData = function(Node, data){
				  Node.grade = data.grade;						  		 
				  Node.isbottom = data.isbottom;
				 
				  Node.cid = data.cid;				  
				  Node.contactid = data.contactid		
				  Node.visitplantempletid = data.visitplantempletid;				  
				};
				treeView.onSelect = function(Node){
				  page_view(Node.id,Node.visitplantempletid,Node.grade, Node.isbottom, Node.cid);
				};
											
				treeView.iniRoot('<%= label.getLabelName("L_ALL")%>');
			});
						

</script>
</head>

<body>

<table width="100%" border="0" cellspacing="0" cellpadding="0"
	height="100%">
	<form name="contacttreeform" method="post" action="../Dispatcher">
	<input type="hidden" name="pagename" value="p_selectlisttree">
	<input type="hidden" name="actionname">
	<input type="hidden"
		name="contactid"> 
	<input type="hidden" name="isbottom">
	<input type="hidden" name="grade"> 
	<input type="hidden" name="cid">
	<input type="hidden" name="visitplantempletid">
	<tr>
		<td valign="top">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td class="summary_top"></td>
			</tr>
		</table>
		<table width="100%" border="1" cellpadding="0"
			bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0"
			align="center" height="92%">
			<tr>
				<td colspan="-1" class="deepblue-left"><img
					src="../images/<%= strLanguageCode %>/quote.gif" width="16"
					height="11"> <%= label.getLabelName("L_TempletMgt") + label.getLabelName("L_Colon") %></td>
			</tr>
			<tr>
				<td cellspacing="0" width="100%">
				<div id=div2 style="OVERFLOW: scroll; WIDTH: 234; HEIGHT: 465">				
				<div id="contacttreeview"></div>
				</td>
			</tr>
			<tr>
				<td class="td-listrom">&nbsp;</td>
			</tr>
		</table>		
		</td>
	</tr>
	</form>
</table>
</body>
</html>